from core.form import FormHandler
import logging

class WordGameFormHandler(FormHandler):    

    def get_template(self, request, game):
        return "wordgame.html"

    def update_parameters(self, request, game, parameters):
        parameters['wordgameprompt'] = game.wordgameprompt
        return parameters
    
    def update_game(self, request, game):
        guess = request.get("guess")
        logging.info("Form Submitted: " + guess)
        logging.info("Correct answer: " + game.wordgameanswer)
        game.wordgame = (guess == game.wordgameanswer)
    
    def get_destination(self, request, game):
        if(hasattr(game,'wordgame')):
            if(game.wordgame):
                return "pantryfood"
        return "wordgame"